<include file="Public/header.html" />
<link href="__PUBLIC__/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<link href="__PUBLIC__/css/edit.css" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/ueditor/third-party/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/umeditor.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<div class="title-box">
    <input type="text" id="txtTitle" maxlength="100" placeholder="输入文章标题">
</div>
<!--style给定宽度可以影响编辑器的最终宽度-->
<script type="text/plain" id="myEditor" style="width:1000px;height:240px;">
</script>
<div >
    <div class="">
        <label class="">文章类型：</label>
        <div class="">
            <select id="selType">
                <option value="0">请选择</option>

            </select>
            <span class="required">*</span>
        </div>
    </div>
    <span >
        <a class="btn btn-sm btn-red-hollow" >发布博客</a>
    </span>
    <div style="margin-bottom: 100px;"></div>


</div>
<script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('myEditor');
    um.addListener('blur',function(){
        $('#focush2').html('')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
</script>


<include file="Public/footer.html" />

<script type="text/javascript">
    $(function () {
        $.ajax({
            url:"{:U('Admin/Index/getTags')}",
            success:function(data){
                $.each(data,function(i,n){
                    var ht = '<option value="'+ n.id+'">'+ n.tag_name+'</option>';
                    $('#selType').append(ht);
                });
            }
        });
    });
    $('.btn-sm').click(function(){
        var str = UM.getEditor('myEditor').getContent();
        var title = $('#txtTitle').val();
        var tag = $('#selType option:selected').val();
        $.ajax({
            url:"{:U('Admin/Index/addArticle')}",
            data:{
                title:title,
                content:str,
                tag:tag
            },
            type:'post',
            success:function(data){
                window.location.href = "{:U('Home/Index/index')}";
            }
        });
    });
</script>